<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link href="https://cdn.bootcdn.net/ajax/libs/animate.css/4.1.1/animate.min.css" rel="stylesheet">
  <style>
    .div1 {
      width: 100px;
      height: 100px;
      background-color: #56a5f1;
      color: #fff;
    }
    .div2 {
      width: 150px;
      height: 150px;
      background-color: red;
      color: #fff;
    }
    .v-enter {
      opacity: 0;
    }
    .v-enter-active {
      transition: opacity 5s;
    }
    .v-enter-to {
      opacity: 1;
    }
    .v-leave {
      opacity: 1;
    }
    .v-leave-active {
      transition: opacity 5s;
    }
    .v-leave-to {
      opacity: 0;
    }
    /* =============================== */
    .ujiuye-enter {
      width: 10px;
    }
    .ujiuye-enter-active {
      transition: width 2s;
    }
    .ujiuye-enter-to {
      width: 150px;
    }
    .ujiuye-leave {
      width: 150px;
    }
    .ujiuye-leave-active {
      transition: width 2s;
    }
    .ujiuye-leave-to {
      width: 10px;
    }
  </style>
</head>

<body>
  <div id="app">
    <p>vue的过渡效果：使元素的变化更加自然、不生硬</p>
    <p>
      1.添加transition组件，将要添加过渡效果的代码放到组件中
      2.写具体的渐变的css代码
      3.css名是相对固定的：v-enter、v-enter-active、v-enter-to、v-leave、v-leave-active、v-leave-to
      4.如果页面中有多个元素需要添加过渡效果，就需要自定义class名，通过transition组件的name属性实现。
    </p>
    <button @click="isShow = !isShow">toggle</button>
    <transition>
      <div v-show="isShow" class="div1">
        我是一段文字
      </div>
    </transition>
    <hr>
    <transition name="ujiuye">
      <div v-show="isShow" class="div2">
        我也是一段文字
      </div>
    </transition>
    <hr>
    <transition
      leave-active-class="animate__bounceIn"
      enter-active-class="animate__bounceOut"
    >
      <div v-show="isShow" class="div2">
        我还是一段文字
      </div>
    </transition>
  </div>
  <script src="./vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        isShow: true
      }
    })
  </script>
</body>

</html>